<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <div id="app">
        <span id="num">{{num}}</span>
        <button @click="num++">赞</button>
        <h2>{{nane}},有{{num}}个人点赞</h2>
</body>

<script src="../node_modules/vue/dist/vue.js"></script>

    <script>

        new Vue({
            el: "#app",
            data: {
                name:"李长锐",
                num:100
            },
            methods:{
                show(){
                    return this.name;
                },
                add(){
                    this.num++;
                }
            },
            //创建之前
            beforeCreate() {
                console.log("=========创建之前beforeCreate========");
                console.log("数据模型未加载：" + this.name,this.num);
                console.log("方法未加载：" + this.show());
                console.log("html模板未加载：" + document.getElementById("num"));
            },
            //创建完成
            created() {
                console.log("=========创建完成created========");
                console.log("数据模型已加载：" + this.name,this.num);
                console.log("方法已加载：" + this.show());
                console.log("html模板已加载：" + document.getElementById("num"));
                console.log("html模板未渲染：" + document.getElementById("num").innerText);
            },
            //挂载之前
            beforeMount() {
                console.log("=========挂载之前beforeMount========");
                console.log("html模板未渲染：" + document.getElementById("num").innerText);
            },
            //挂载完成
            mounted() {
                console.log("=========mounted========");
                console.log("html模板已渲染：" + document.getElementById("num").innerText);
            },
            //更新之前 针对vue的数据更新才发生的生命周期
            beforeUpdate() {
                console.log("=========beforeUpdate========");
                console.log("数据模型已更新：" + this.num);
                console.log("html模板未更新：" + document.getElementById("num").innerText);
            },
            //更新之后 针对vue的数据更新才发生的生命周期
            updated() {
                console.log("=========updated========");
                console.log("数据模型已更新：" + this.num);
                console.log("html模板已更新：" + document.getElementById("num").innerText);
            },
        });

        
        
    </script>
</html>